# coding=utf-8
import time
cnt = 0
f = open('test.txt', 'a', encoding='UTF-8')
while True:
    print('***'+str(cnt)+'\n')
    f.write('***'+str(cnt)+'\n')
    f.flush()
    time.sleep(3)
    cnt += 1
f.close()

